package com.bw.shop_2302.adapter

import android.graphics.Paint
import android.widget.ImageView
import android.widget.TextView
import com.bw.base.entity.Goods
import com.bw.shop_2302.R
import com.bw.shop_2302.utils.GlideUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class GoodsAdapter:BaseQuickAdapter<Goods,BaseViewHolder>(R.layout.item_goods) {
    override fun convert(holder: BaseViewHolder, item: Goods) {
        val view = holder.getView<ImageView>(R.id.iv_goods)
        GlideUtils.circleCropimag(context,item.image,view)
        holder.setText(R.id.tv_goodsstoreName,item.storeName)
        holder.setText(R.id.tv_goodsprice,"￥ ${item.price}")
        holder.setText(R.id.tv_goodsopprice,"￥ ${item.otPrice}")
        holder.setText(R.id.tv_goodssale,"已售${item.sales+item.ficti}件")//将实体类中的sales和ficti该为Int类型

        //给原价添加中划线
        val textView = holder.getView<TextView>(R.id.tv_goodsopprice)
        textView.paintFlags= Paint.STRIKE_THRU_TEXT_FLAG //设置中划线


    }
}